import { Injectable } from '@nestjs/common';
import { ResponseUtil } from '../common/utils/response.util';
@Injectable()
export class IngressService {

      public ingressList = {
        list: [
          {
            name: "payment-service-ingress",
            hosts: "pay.example.com, payment.example.com",
            createTime: "2025-08-15T08:30:00Z"
          },
          {
            name: "user-api-ingress",
            hosts: "users.example.com",
            createTime: "2025-08-10T14:20:00Z"
          },
          {
            name: "order-staging-ingress",
            hosts: "orders-staging.example.com",
            createTime: "2025-08-20T09:15:00Z"
          },
          {
            name: "admin-panel-ingress",
            hosts: "admin.example.com, dashboard.example.com",
            createTime: "2025-07-05T16:45:00Z"
          },
          {
            name: "analytics-ingress",
            hosts: "analytics.example.com",
            createTime: "2025-09-01T11:00:00Z"
          }
         ]
      };
      postListIngress() {
        return ResponseUtil.success(this.ingressList);
      }


      public ingressDetail = {
        name: "payment-service-ingress",
        hosts: "pay.example.com, payment.example.com",
        createTime: "2025-08-15T08:30:00Z"
      };
      postGetIngress() {
        return ResponseUtil.success(this.ingressDetail);
      }

      postDeleteIngress(body: any) {
        const currentIndex = this.ingressList.list.findIndex(item => item.name === body.name);
        this.ingressList.list.splice(currentIndex, 1);
        return ResponseUtil.success(null, '删除成功');
      }
}
